﻿using AutoMapper;
using IOA.MES.DataAccess.Entity;
using IOA.MES.DataAccess.Enum;
using IOA.MES.DataAccess.VModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IOA.MES.Business
{
    /// <summary>
    /// 颜色管理（错误代码：141001）
    /// </summary>
    public class ColorMgr
    {
        private MESContext mesDb = new MESContext("MES");

        /// <summary>
        /// 查询颜色列表
        /// </summary>
        /// <param name="colorType">颜色类型</param>
        /// <returns>颜色列表</returns>
        public List<VColorSet> QueryColors(ColorType? colorType = null)
        {
            var query = mesDb.ColorSets.Where(_ => _.Valid);
            if (colorType.HasValue)
            {
                query = query.Where(_ => _.ColorType == colorType.Value);
            }
            var entities = query.ToList();

            return Mapper.Map<List<VColorSet>>(entities);
        }
    }
}
